import os, sys

mode = ARGUMENTS.get('mode', 'release')   #holds current mode
if mode != "debug":
    mode = "release"
builddir = "build/" + mode
env = Environment(ENV = {'PATH' : os.environ['PATH']}, MODE = mode, BUILD = builddir)

env.VariantDir(builddir, 'src', duplicate=0)

if mode == 'debug':
    env.Append(CCFLAGS = ['-Wall', '-g', '-DDEBUG', '-O0'])
else:
    env.Append(CCFLAGS = ['-Wall'])

env.Append(LIBS = ["-lenet"])

if sys.platform.startswith("win"):
    env.Append(LIBS = ["-lwsock32", "-lws2_32", "-lwinmm"])

env.ParseConfig("pkg-config --static --cflags --libs gthread-2.0")
env.ParseConfig("pkg-config --static --cflags --libs glib-2.0")
server=env.Program(source=["$BUILD/enet-server.c", "$BUILD/logging.c"],target="bin/$MODE/mps-server")
client=env.Program(source=["$BUILD/enet-client.c", "$BUILD/logging.c", "$BUILD/mplayer-control.c"],target="bin/$MODE/mps-client")

env.Install("/usr/bin", server)
env.Install("/usr/bin", client)
env.Alias('install', ['/usr/bin'])
